<?php

namespace App\Http\Controllers;

use Laravel\Lumen\Routing\Controller as BaseController;
use App\Core\ApiSpec;
use App\Http\Controllers\ErrorCode;
class Controller extends BaseController
{
    public function __construct(ApiSpec $ApiSpec)
    {
        $this->ApiSpec = $ApiSpec;
    }
    //
    protected function response_object($object)
    {
	$data = $this->ApiSpec->gen_object($object);
	return response()->json($data);
    }
    
    protected function response_error($code, $info = null)
    {
	if (empty($info)) {
	    $info = ErrorCode::desc($code);
        }
	$data = $this->ApiSpec->gen_error($code, $info);
	return response()->json($data);
    }
}
